package com.zhouyipeng;


import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class CalculateRMB {

    // 平台到手
    private static double ratio = 0.63D;

    // 折扣礼物
    private static double discount = 0.80D;

    // 麦序奖励
    static class Award{
        private String wage;
        private double rmb;
        private int hour;

        public String getWage() {
            return wage;
        }

        public void setWage(String wage) {
            this.wage = wage;
        }

        public double getRmb() {
            return rmb;
        }

        public void setRmb(double rmb) {
            this.rmb = rmb;
        }

        public int getHour() {
            return hour;
        }

        public void setHour(int hour) {
            this.hour = hour;
        }
    }

    /**
     * 构建脉序奖励
     * @return
     */
    private static List<Award> buildAward(){
        List<Award> retList = new ArrayList<>(7);

        Award a = new Award();
        a.setWage("5");
        a.setRmb(100D);
        retList.add(a);

        Award b = new Award();
        b.setWage("6");
        b.setRmb(300D);
        retList.add(b);

        Award c = new Award();
        c.setWage("7");
        c.setRmb(500D);
        retList.add(c);

        Award d = new Award();
        d.setWage("8");
        d.setRmb(1000D);
        retList.add(d);

        Award e = new Award();
        e.setWage("10");
        e.setRmb(2000D);
        retList.add(e);

        Award f = new Award();
        f.setWage("15");
        f.setRmb(3500D);
        retList.add(f);

        Award g = new Award();
        g.setWage("20");
        g.setRmb(5000D);
        retList.add(g);

        return  retList;
    }

    public static void main(String[] args) {
        List<Award> awards = buildAward();

        awards.forEach(award -> {
            double rmb = award.getRmb();
            String wage = award.getWage();
            System.out.println("时薪："+ wage);
            System.out.println("目标："+ rmb);
            System.out.println("成本："+ (int)(rmb * discount));
            System.out.println("缺口："+ (int)(rmb * (discount - ratio)));

            BigDecimal divide = new BigDecimal(String.valueOf(rmb * (discount - ratio))).divide(new BigDecimal(wage),2,BigDecimal.ROUND_HALF_UP);
            System.out.println(divide.toString() +"个麦序开始盈利");
            System.out.println("===========");
        });
    }

}
